package com.syq.controller;

import com.syq.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * @ClassName: ParamController
 * @Description: TODO
 * @Create by: syq
 * @Date: 2022/7/13 10:54
 */
@Controller
@RequestMapping("/json")
public class JsonController {

    /**
     * 接收 json串并转成对象
     *  json:        {"id":123,"name":"小小"}
     *
     *  @RequestBody : 底层 jackson 进行JSON转换
     *                 底层改成fastjson   进行JSON转换
     */
    @PostMapping("/send")
    @ResponseBody
    public User send(@RequestBody User user){
        System.out.println("user:" + user);
        user.setId(888);
        user.setName("磊大大");
        user.setBirthday(new Date());
        return user;
    }
}
